{extend name="index/index" /}

<!--main-->
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="#">用户管理</a>
            </li>
            <li class="active">用户列表</li>
        </ul><!-- .breadcrumb -->

        <!--<div class="nav-search" id="nav-search">-->
            <!--<form class="form-search">-->
                                <!--<span class="input-icon">-->
                                    <!--<input type="text" placeholder="Search ..." class="nav-search-input"-->
                                           <!--id="nav-search-input" autocomplete="off"/>-->
                                    <!--<i class="icon-search nav-search-icon"></i>-->
                                <!--</span>-->
            <!--</form>-->
        <!--</div>&lt;!&ndash; #nav-search &ndash;&gt;-->
    </div>

    <div class="page-content">
        <div class="page-header">
            <h1>
                会员
                <small>
                    <i class="icon-double-angle-right"></i>
                    会员列表
                </small>
            </h1>
        </div><!-- /.page-header -->

        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->

                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th class="center">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </th>
                                    <th>ID</th>
                                    <th>IDENTITY</th>
                                    <th>Tel</th>
                                    <th class="hidden-480">Nickname</th>
                                    <th>
                                        <i class="icon-time bigger-110 hidden-480"></i>
                                        LastTime
                                    </th>
                                    <th class="hidden-480">Status</th>
                                    <th class="hidden-480">Action</th>
                                </tr>
                                </thead>

                                <tbody>

                                {volist name="data" id="v"}
                                <!--tr-->
                                <tr>
                                    <td class="center">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>

                                    <td>
                                        <a href="#">{$v['id']}</a>
                                    </td>
                                    {switch name="v.dw_num"}
                                    {case value="1"}
                                    <td style="color: #caf">普通用户</td>
                                    {/case}
                                    {case value="0"}
                                    <td style="color: #caf">普通用户</td>
                                    {/case}
                                    {case value="3"}
                                    <td style="color: red">超级会员</td>
                                    {/case}
                                    {/switch}
                                    <td class="hidden-480">{$v['tel']}</td>
                                    <td>{$v['nickname']}</td>
                                    {if condition="$v.login_time"}
                                    <td>{$v['login_time']|date="Y-m-d H:i:s",###}</td>
                                    {else/}
                                    <td>无记录</td>
                                    {/if}
                                    <td class="hidden-480">
                                            {switch name="v.status"}
                                            {case value="0"}
                                                <label>
                                                    <input name="switch-field-1" class="ace ace-switch acti-btn"  type="checkbox"  data-id="{$v.id}" />
                                                    <span class="lbl"></span>
                                                </label>
                                            {/case}
                                            {case value="1"} 
                                                <label>
                                                    <input name="switch-field-1" class="ace ace-switch acti-btn"  type="checkbox" checked data-id="{$v.id}" />
                                                    <span class="lbl"></span>
                                                </label>
                                            {/case}
                                            {/switch}
                                    </td>
                                    <td>
                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                            <!-- 查看 -->
                                            <a class="blue show-btn"   data-toggle="modal" data-target="#showModal" data-id="{$v['id']}" >
                                                <i class="icon-zoom-in bigger-130"></i>
                                            </a>
                                            <!-- End查看 -->
                                            <!-- 编辑 -->
                                            <a class="green" href="{:url('admin/member/edit', ['id'=>$v['id']])}" id="edit-btn" data-id="{$v['id']}" >
                                                <i class="icon-pencil bigger-130"></i>
                                            </a>
                                            <!-- END 编辑 -->
                                            <!-- 删除 -->
                                            <a class="red del-btn"  data-id="{$v['id']}">
                                                <i class="icon-trash bigger-130"></i>
                                            </a>
                                            <!-- END 删除 -->
                                        </div>
                                        <div class="visible-xs visible-sm hidden-md hidden-lg">
                                            <div class="inline position-relative">
                                                <button class="btn btn-minier btn-yellow dropdown-toggle"
                                                        data-toggle="dropdown">
                                                    <i class="icon-caret-down icon-only bigger-120"></i>
                                                </button>

                                                <ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
                                                    <li>
                                                        <a href="#" class="tooltip-info" data-rel="tooltip"
                                                           title="View">
                                                            <span class="blue">
                                                                <i class="icon-zoom-in bigger-120"></i>
                                                            </span>
                                                        </a>
                                                    </li>

                                                    <li>
                                                        <a href="#" class="tooltip-success" data-rel="tooltip"
                                                           title="Edit">
                                                            <span class="green">
                                                                <i class="icon-edit bigger-120"></i>
                                                            </span>
                                                        </a>
                                                    </li>

                                                    <li>
                                                        <a class="tooltip-error " data-rel="tooltip"
                                                           title="Delete" >
                                                            <span class="red">
                                                                <i class="icon-trash bigger-120"></i>
                                                            </span>
                                                        </a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <!--endtr-->
                                {/volist}
                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div><!-- /.main-content -->


</div><!-- /#ace-settings-container -->
</div><!-- /.main-container-inner -->

<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a>
</div><!-- /.main-container -->

<!-- 用户信息模态框 -->
<div class="modal fade" id="showModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">用户信息</h4>
      </div>
      <div class="modal-body">
        <div class="col-md-12">
            <div class="col-md-4">
                <img src="" alt="" class="img-circle modal-icon" width="100px" height="100px">
            </div>
            <div class="col-md-8">
                <div class="table-responsive">
                  <table class="table table-hover" style="background-color: #fff">
                    <tbody>
                         <tr>
                            <th>ID</th>
                            <td class="modal-id"></td>
                        </tr>
                        <tr>
                            <th>登录名</th>
                            <td class="modal-tel"></td>
                        </tr>
                        <tr>
                            <th>状态</th>
                            <td class="modal-status"></td>
                        </tr>
                        <tr>
                            <th>性别</th>
                            <td class="modal-sex"></td>
                        </tr>
                        <tr>
                            <th>生日</th>
                            <td class="modal-birthday"></td>
                        </tr>
                        <tr>
                            <th>邮箱</th>
                            <td class="modal-email"></td>
                        </tr>
                        <tr>
                            <th>qq</th>
                            <td class="modal-qq"></td>
                        </tr>
                        <tr>
                            <th>创建时间</th>
                            <td class="modal-regime"></td>
                        </tr>
                    </tbody>
                  </table>
                </div>
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<!-- END 模态框 -->

{/block}
<!-- basic scripts -->

<!--[if !IE]> -->

<script src="/static/admin/js/jquery.min.js"></script>

<!-- <![endif]-->

{block name="myjs" }
<!--[if IE]>
<script src="/static/admin/js/1.10.2/jquery.min.js"></script>
<![endif]-->

<!--[if !IE]> -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='/static/admin/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='/static/admin/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='/static/admin/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="/static/admin/js/bootstrap.min.js"></script>
<script src="/static/admin/js/typeahead-bs2.min.js"></script>

<!-- page specific plugin scripts -->

<script src="/static/admin/js/jquery.dataTables.min.js"></script>
<script src="/static/admin/js/jquery.dataTables.bootstrap.js"></script>

<!-- ace scripts -->

<script src="/static/admin/js/ace-elements.min.js"></script>
<script src="/static/admin/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">
 /*=========================================*/

 // AJAX激活禁用操作
 $(function(){
    $('.acti-btn').click(function(){
        var id = $(this).attr('data-id');
                $.ajax({
                type:'get',
                data:{'id':id},
                url:'adminDoaction',
                dataType:'json',
                success:function(data){
                    if(data.status){
                        $(this).prop("checked", false);
                        toastr.success(data.info);
                    }else{
                        toastr.success(data.info);
                    }
                },
            error:function(){
                toastr.error('网络错误,禁用失败');
            }
        });
       });
//END ajax 激活禁用操作

// ajax 执行删除
    $('.del-btn').click(function(){
        var id = $(this).attr('data-id');
        var obj = $(this).parents('tr');
        if(confirm('你确定要删除吗?')){
            delAjax(id,obj);
        }
    });
    });
//ajax 执行查看相关信息
    $('.show-btn').click(function(){
        var id  = $(this).attr('data-id');
        showAjax(id);
    });
    // 执行删除资源的操作
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/adminmember/' + id,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                toastr.error('网络请求失败....');
            }
        });
}


    // 执行查询单条资源的操作
    function showAjax(id) {
        $.ajax({
            type: 'get',
            url: '/adminmember/' + id,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if(data){
                    $('.modal-id').html(data.id);
                    $('.modal-status').html(data.status);
                    $('.modal-age').html(data.age);
                    $('.modal-nickname').html(data.nickname);
                    $('.modal-email').html(data.email);
                    $('.modal-tel').html(data.tel);
                    $('.modal-qq').html(data.qq);
                    $('.modal-regime').html(data.regime);
                    $('.modal-birthday').html(data.birthday);
                    $('.modal-icon').html(data.icon);
                    switch (data.sex) {
                    case (0):
                        $('.modal-sex').html('女');
                        break;
                    case (1):
                       $('.modal-sex').html('男');
                        break;
                    case (2):
                       $('.modal-sex').html('保密');
                        break;
                    default:
                }
                if(data.status==1){
                    $('.modal-status').html('激活');
                }else{
                    $('.modal-status').html('禁用');
                }
                }else{
                    toastr.error('查询失败');
                    return false;
                }

                if(data.icon){
                    $('.modal-icon').removeAttr('src');
                    $('.modal-icon').attr('src','http://pdyc9epam.bkt.clouddn.com/'+data.icon);
                }else{
                    $('.modal-icon').removeAttr('src');
                    $('.modal-icon').attr('src','static/default.jpg');
                }
            },
            error: function () {
                toastr.error('网络错误......');
                return false;
            }
        });
    }
 /*=========================================*/


    jQuery(function ($) {
        var oTable1 = $('#sample-table-2').dataTable({
            "aoColumns": [
                {"bSortable": false},
                null, null, null, null, null,
                {"bSortable": false}
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })

</script>
{/block}

<div style="display:none">
    <script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script>
</div>
</body>
</html>
